<?php
namespace Clover\Controller;

use Think\Controller;

class LoginController extends BaseController
{
    public function index()
    {
        $login_status = D("Clover/Admin")->get_login_status();
        if ($login_status) {
            $this->redirect("/Clover");
        } else {
            $this->display("login");
        }
    }

    /**
     * 登入后台
     */
    public function login_manager()
    {
        $username = I("post.dsk_username");
        $password = I("post.dsk_password");
        $arr_res = D("Clover/Admin")->check_account($username, $password);
        //echo session('admin_username');
        //echo "ddd";
        if ($arr_res['status'] == 0) {
            // $expire=3600*24*30;
            // cookie('show_hide','2', $expire);
            $this->redirect('/Clover');
        } else {
            $this->assign(array("des" => "用户名或密码错误"));
            $this->display('login');
        }
    }

    /**
     * 登出后台
     */
    public function logout_manager()
    {
        session(null);
        $this->redirect('/Clover');
    }
}